// xc/components/diy/tabpro/unitcss.js
const cart = require('../../../sys/cart')
var behaviorsbasic = require('../../behavior/basic')
const app = getApp()

Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  behaviors: [behaviorsbasic],
  /**
   * 组件的属性列表
   */
  properties: {  
    objmodel: {
      type: Object,
      default: ''
    },
    cartproitem:{
     type:String,
     default: ''
    },
    item: {
      type: Object,
      default: ''
    },
    
  },

  /**
   * 组件的初始数据
   */
  data: {
    basicurl: app.globalData.basicurl,
  },
  ready(){
    
    if(!app.globalData.basicurl || app.globalData.basicurl==-1){
  
      this.setbasicurl()
    }else{
      this.setData({
        basicurl:app.globalData.basicurl
      })
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    navigateTo(ev){
      var dataset = ev.currentTarget.dataset
      var item = dataset.item;
      wx.navigateTo({
        url: '/xc_lshop/club/clubshop/pro/proinfo?id='+item.id,
      })
      
    },
    setbasicurl(){
      var that=this;
      var app = getApp()
     
      var basicurl=app.globalData["xcsys"]['basicurl']+'/addons/'+app.globalData["xcsys"]['m']+'/';
      that.setData({basicurl:basicurl})
      app.globalData.basicurl=basicurl;
     
    },
    noevent(ev) {
      //用来阻止用的， 其它没什么用处

   
    },
    cartop(ev){
      var item=ev.currentTarget.dataset.item
      if(item.stock>0){
        this.triggerEvent('cartop', ev.detail)
      }else{
        wx.showToast({
          icon:"none",
          title: '商品已售罄',
        })
      }
   

    }
  }
})
